package concurrent.notreentrantlock;

/**
 * 实现了一个简易的不可重入锁
 */
public class MyNoReentrantLock {

    private boolean isLocked = false;

    public synchronized void lock() throws InterruptedException{

        while(isLocked) {
            wait();
        }
        isLocked = true;
    }
    public synchronized void unlock() {
        isLocked = false;
        notify();
    }
}
